package com.ruoyi.web.controller.commentmanage;

import com.ruoyi.commentmanage.domain.CmComment;
import com.ruoyi.commentmanage.service.ICmCommentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.IdList.idList;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.useradmin.domain.UaUser;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @Description  
 * @author kemonvvv
 * @Date 2023-06-05 
 */
@RestController
@RequestMapping("commentmanage/cmComment")
public class CmCommentController extends BaseController {

    @Resource
    private ICmCommentService cmCommentService;
    /**
     * 通过全查询
     *  params是用若依的特殊处理过的，不能直接用url去测试，只能用若依的主键写代码去测试
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:query')")
    @PostMapping("/getCmCommentPage")
    public AjaxResult getCmCommentPage(@RequestBody PageDomain pageDomain,@RequestBody CmComment cmComment) {
        Object data = cmCommentService.getCmCommentPage(pageDomain, cmComment);
        return AjaxResult.success(data);
    }

    /**
     * 通过查询全部
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:query')")
    @PostMapping("/getCmCommentList")
    public AjaxResult getCmCommentList() {
        Object data = cmCommentService.getCmCommentList();
        return AjaxResult.success(data);
    }
    
    /**
     * 通过id查询
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:query')")
    @PostMapping("/getCmCommentById")
    public AjaxResult getCmCommentById(@RequestBody Map<String,Long> idMap) {
        Object data = cmCommentService.getCmCommentById(idMap.get("id"));
        return AjaxResult.success(data);
    }

    /**
     * 添加
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:add')")
    @PostMapping("/insertCmComment")
    public AjaxResult insertCmComment(@RequestBody CmComment cmComment) {
        Object data = cmCommentService.insertCmComment(cmComment);
        return AjaxResult.success(data);
    }

    /**
     * 更新
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:edit')")
    @PostMapping("/updateCmComment")
    public AjaxResult updateCmComment(@RequestBody CmComment cmComment) {
        Object data = cmCommentService.updateCmCommentById(cmComment);
        return AjaxResult.success(data);
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('commentmanage:cmComment:remove')")
    @PostMapping("/deleteCmCommentByIdList")
    public AjaxResult deleteCmCommentByIdList(@RequestBody idList idList) {
        Object data = cmCommentService.deleteCmCommentByIdList(idList.getIdList());
        return AjaxResult.success(data);
    }

}
